import parser from 'ua-parser-js';

const getUserAgent = () => {
    try {
        return parser(window.navigator.userAgent);
    } catch {
        return false;
    }
};
const userAgent = getUserAgent();
const browser = userAgent && userAgent.browser ? userAgent.browser : undefined;
const isChrome = browser && browser.name === 'Chrome';
const isFirefox = browser && browser.name === 'Firefox';
const browserName = isChrome || isFirefox ? browser.name : undefined;

export default { userAgent, browserName, isChrome, isFirefox };
